package com.elitecrm.util;

import java.util.Random;

public class StringUtil {
	public static String parseNull(Object obj){
		if(obj == null){
			return "";
		}
		return obj.toString();
	}
	
	public static int parseInt(String source){
		int ret = 0;
		if(source!=null){
			try{
				ret = Integer.parseInt(source);
			}catch(Exception e){}
		}
		return ret;
	}
	
	public static boolean isNotNull(String target){
		if(target==null || target.equals("")){
			return false;
		}
		return true;
	}
	
	
	public static String generateRandomStr(int length){
		String base = "abcdefghijklmnopqrstuvwxyz0123456789";   
	    Random random = new Random();   
	    StringBuffer sb = new StringBuffer();   
	    for (int i = 0; i < length; i++) {   
	        int number = random.nextInt(base.length());   
	        sb.append(base.charAt(number));   
	    }   
	    return sb.toString();   
	}
}
